<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>外部账号管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" type="text/css" href="assets/layui/css/layui.css" />
	</head>
	<body class="out-account">
		<span class="layui-breadcrumb">
	    <a>系统管理</a>
		<a><cite>外部账号管理</cite></a>
	</span>
		<div class="layui-fluid">
			<div class="carTable">
				<div class="layui-inline">
					<input type="text" name="title" placeholder="搜索" autocomplete="off" class="layui-input" id="reloadContent">
				</div>
				<button class="layui-btn" data-type="reload">搜索</button>
			</div>
			<table class="layui-hide" id="out-account-table" lay-filter="outaccount"></table>
			<script type="text/html" id="checkInfor">
				<a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
			</script>
			<button class="layui-btn" id="createoutAccount">创建邀请码</button>
			<button class="layui-btn" id="auditList">审核列表</button>
		</div>
		<script src="assets/layui/layui.js" type="text/javascript"></script>
	  <script src="assets/js/all.js" type="text/javascript"></script>
		<script type="text/javascript">
			layui.use(['form', 'table', 'layer', 'laypage'], function() {
				var form = layui.form,
					table = layui.table,
					layer = layui.layer,
					laypage = layui.laypage,
					$ = layui.$
				//方法级渲染
				var tableIn = table.render({
					elem: '#out-account-table',
					url: 'assets/data/account.json',
					cols: [
						[{
							field: 'id',
							title: '账号',
							width: 80
						}, {
							field: 'phone',
							title: '联系方式',
							width: 130
						}, {
							field: 'email',
							title: 'Email',
							width: 130
						}, {
							field: 'company',
							title: '企业名称'
						}, {
							field: 'sign',
							title: '身份'
						}, {
							field: 'experience',
							title: '权限'
						}, {
							//fixed: 'right',
							align: 'center',
							toolbar: '#checkInfor'
						}]
					],
					id: 'testReload',
					page: true,
					limit: 20, //每页默认显示的数量
					done: function(res, curr, count) { //res即为你接口返回的信息,curr 是当前页，count总页数
						if(res.code == 0) {
							layer.msg(res.msg);
						}
						if(res.code == 1) {

						}
					}
				});

				$('.carTable .layui-btn').on('click', function() {
					var reloadContent = $("#reloadContent").val()
					//执行重载
					tableIn.reload('testReload', {
						page: {
							curr: 1 //重新从第 1 页开始
						},
						where: {
							key: reloadContent
						}
					});
				});

				//监听工具条
				table.on('tool(outaccount)', function(obj) {
					var data = obj.data;
					if(obj.event === 'detail') {
						var index = layer.open({
							type: 2,
							title: '账号信息',
							area: ['700px', '450px'],
							fixed: false, //不固定
							maxmin: true,
							content: 'addNewAccount.html' // + data.id
						});
						layer.full(index);

					} else if(obj.event === 'del') {
						layer.confirm('真的删除此行信息么', function(index) {
							obj.del();
							layer.close(index);
						});
					}
					//  else if(obj.event === 'edit'){
					//    layer.msg('ID：'+ data.id + ' 的查看操作');
					//  }
				});
				//添加新外部账号-创建邀请码
				$("#createoutAccount").on("click", function() {
					var index = layer.open({
						type: 2,
						title: '账号信息',
						area: ['700px', '450px'],
						fixed: false, //不固定
						maxmin: true,
						content: 'addCode.html'
					});
					layer.full(index);
				});
				//打开审核列表
				$("#auditList").on("click", function() {
					var index = layer.open({
						type: 2,
						title: '审核列表',
						area: ['900px', '550px'],
						fixed: false,
						maxmin: true,
						content: 'auditList.html'
					});
					layer.full(index);
				});
			})
		</script>
	</body>
</html>